/*
	PandaForum: PHP Forum Engine
	
	Jesse Gill, 0108377707
*/

function acp_forums_refreshlist()
{
	var httpObj = createHTTPObject();
	
	if (httpObj == false)
	{
		return;
	}
	
	httpObj.onreadystatechange=function()
	{
		if(httpObj.readyState==4)
		{
			document.getElementById('forumlist').innerHTML = httpObj.responseText;
		}
	}
	
	httpObj.open("GET", "src/ajax_retrieve/ar_acp-forums_forumlist.php", true);
	httpObj.send(null);
}

function ajax_removeforum(id)
{
	var httpObj = createHTTPObject();
	
	if (httpObj == false)
	{
		return;
	}
	
	httpObj.onreadystatechange=function()
	{
		if(httpObj.readyState==4)
		{
			document.getElementById('results').innerHTML = httpObj.responseText;
			
			acp_forums_refreshlist();
		}
	}
	
	var url = "removeforum_db.php?id=" + id;
	
	httpObj.open("GET", url, true);
	httpObj.send(null);
}

function ajax_addforum(name, category)
{
	var httpObj = createHTTPObject();
	
	if (httpObj == false)
	{
		return;
	}
	
	httpObj.onreadystatechange=function()
	{
		if(httpObj.readyState==4)
		{
			document.getElementById('results').innerHTML = httpObj.responseText;
			
			acp_forums_refreshlist();
		}
	}
	
	var url = "addforum_db.php?name=" + name;
	url += "&category=" + category;
	
	httpObj.open("GET", url, true);
	httpObj.send(null);
}

function ajax_removecategory(id)
{
	var httpObj = createHTTPObject();
	
	if (httpObj == false)
	{
		return;
	}
	
	httpObj.onreadystatechange=function()
	{
		if(httpObj.readyState==4)
		{
			document.getElementById('results').innerHTML = httpObj.responseText;
			
			acp_forums_refreshlist();
		}
	}
	
	var url = "removecategory_db.php?id=" + id;
	
	httpObj.open("GET", url, true);
	httpObj.send(null);
}

function ajax_addcategory(name)
{
	var httpObj = createHTTPObject();
	
	if (httpObj == false)
	{
		return;
	}
	
	httpObj.onreadystatechange=function()
	{
		if(httpObj.readyState==4)
		{
			document.getElementById('results').innerHTML = httpObj.responseText;
			
			acp_forums_refreshlist();
		}
	}
	
	var url = "addcategory_db.php?name=" + name;
	
	httpObj.open("GET", url, true);
	httpObj.send(null);
}
